package com.boho.system.action;


             
/**
 * @File name:  ManagerUserPermissionAction.java 
 * @Create on:  2010-05-10 19:30:171
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        

            
import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.service.MessageService;

import com.boho.common.Utils;
import com.boho.system.service.PermissionService;

public class ManagerUserPermissionAction extends ActionImp {
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		atx.setErrorContext("FSTI_SYS_PERMISSION_1001", MessageService.getMessage("FSTI_SYS_PERMISSION_1001"),"【系统功能】" ,ex);
	}
	@SuppressWarnings("unchecked")
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		Integer userid = atx.getIntegerValue("USER_ID", 0);
		Object[] obj = atx.getArrayValue("ROLE_ID");
		Integer[] roleids = Utils.ObjArrayToIntArray(obj);
		String[] funids = (String[])atx.getArrayValue("FUNCTION_ID");
		Object[] dobj = atx.getArrayValue("DEPARTMENT_NO");
		Integer[] departIds = Utils.ObjArrayToIntArray(dobj);
		PermissionService.updateUserRole(atx, userid, roleids);
		PermissionService.updateUserFunction(atx, userid, funids);
		PermissionService.updateUserDepartment(atx, userid, departIds);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		return 1;
	}
}
